/*
 * Copyright (C) UnionTech Software Technology Co., Ltd.
 *
 * Author:     caitao <caitao@uniontech.com>
 *
 * Maintainer: caitao <caitao@uniontech.com>
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
#include "firewalldetailpage.h"
#include "dlistviewmulticol.h"
#include "dlistviewmulticolheaderview.h"

#include <QDebug>
#include <QVBoxLayout>
#include <QLabel>
#include <QListView>
#include <QLineEdit>

//////控件测试
#include <DToolTip>
#include <DStandardItem>
#include <DListView>
#include <QAbstractItemView>

DWIDGET_USE_NAMESPACE

FirewallDetailPage::FirewallDetailPage(QWidget *parent)
    : QWidget(parent)
{
    // test
    QStandardItemModel *m_model = new QStandardItemModel(this);
    // head view
    QHeaderView *m_headerView = new QHeaderView(Qt::Orientation::Horizontal, this);

    DListViewMultiCol *listViewMultiCol = new DListViewMultiCol(m_model, m_headerView, this);

    for (int i = 0; i < 20; i++) {
        QList<QStandardItem *> itemList;
        QStandardItem *nameItem = new QStandardItem(QString("name%1").arg(i));
        nameItem->setIcon(QIcon::fromTheme("deepin-defender"));
        QStandardItem *timeItem = new QStandardItem(QString("20210810-%1").arg(i));
        timeItem->setData(QVariant::fromValue<QColor>(Qt::GlobalColor::green), Qt::ItemDataRole::TextColorRole);
        QStandardItem *opItem = new QStandardItem("add");
        itemList << nameItem << timeItem << opItem;
        m_model->appendRow(itemList);
    }

    m_model->setHorizontalHeaderItem(0, new QStandardItem("name"));
    m_model->setHorizontalHeaderItem(1, new QStandardItem("time"));
    m_model->setHorizontalHeaderItem(2, new QStandardItem("op"));
    m_headerView->resizeSection(0, 100);
    m_headerView->resizeSection(1, 200);
    m_headerView->setSortIndicator(0, Qt::SortOrder::DescendingOrder);

    QVBoxLayout *mainLayout = new QVBoxLayout(this);
    setLayout(mainLayout);

    mainLayout->addWidget(listViewMultiCol);

    DListViewMultiColHeaderView *headView = new DListViewMultiColHeaderView(Qt::Orientation::Horizontal, this);
    headView->setModel(listViewMultiCol->model());
    headView->hide();
}
